/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package di.persistence.entities;

import di.persistence.entities.interfaces.IEntity;
import di.persistence.entities.interfaces.ILabeled;
import di.persistence.entities.interfaces.ILocalisation;
import di.persistence.entities.interfaces.IUpdate;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Kilian Ito
 */
@Entity
public class Position implements IEntity, ILocalisation, ILabeled {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;
    @Temporal(TemporalType.TIME)
    protected Date UpdateTime;
    protected Float latitude;
    protected Float longitude;
    protected String label;

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    public Float getLatitude() {
        return latitude;
    }

    public void setLatitude(Float latitude) {
        this.latitude = latitude;
    }

    public Float getLongitude() {
        return longitude;
    }

    public void setLongitude(Float longitude) {
        this.longitude = longitude;
    }

    @Override
    public Date getUpdateTime() {
        return UpdateTime;
    }

    @Override
    public void setUpdateTime(Date UpdateTime) {
        this.UpdateTime = UpdateTime;
    }

    @Override
    public String getLabel() {
        return label;
    }

    @Override
    public void setLabel(String label) {
        this.label = label;
    }
    
    

    
    
    @PrePersist
    @PreUpdate
    protected void updateDate() {
        setUpdateTime(new Date());
    }
    
    
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Position)) {
            return false;
        }
        Position other = (Position) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Latitude:" +getLatitude()+"; Logitude:"+getLongitude();
    }
    
}
